<!--
Date: 2025-08-13
Copyright (c) 2025 CAX Conversion Project
-->
<template>
  <el-dialog title="表结构" v-model="props.tableFiledVisible" @close="close" >
    <div style="margin-bottom: 10px;" >数据库表名：{{ props.currentData?.name }}</div>
    <el-table :data="tableData">
      <el-table-column label="序号" type="index" width="60"></el-table-column>
      <el-table-column label="数据库字段" prop="targetField"></el-table-column>
      <el-table-column label="数据库字段类型" prop="targetFieldType"></el-table-column>
      <el-table-column label="数据库字段长度" prop="targetFieldLength"></el-table-column>
      <el-table-column label="是否必填">
        <template #default="scope">
          <div>{{ scope.row.needFlag === '1' ? '必填' : '非必填' }}</div>
        </template>
      </el-table-column>
    </el-table>
    <template #footer>
      <div class="dialog-footer">
        <el-button size="small" type="primary" @click="close"> 关闭 </el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup>
import { queryTableFileds } from '@/api/metaData/index';
const props = defineProps(['tableFiledVisible', 'currentData']);
const emit = defineEmits(['handleEvent']);
const tableData = ref([]);
const getTableFileds = () => {
  queryTableFileds({ tableName: props.currentData?.name }).then((res) => {
    if (res) {
      const result = res?.data || [];
      tableData.value = result[0].mapFiledsList || [];
    }
  });
};
const close = ()=>{
    emit('handleEvent');
}
onMounted(() => {
  getTableFileds();
});
</script>
<style lang="scss" scoped>
</style>